<template>
  <view v-if="formList.length > 0">
    <!--反馈内容-->
    <u-card v-if="props.taskInfo.taskType === 1">
      <template #head>
        <u-icon
          size="28"
          custom-prefix="custom-icon"
          color="#0177fd"
          name="wenjian"
        ></u-icon>
        <text class="u-m-l-10 font-bold u-font-lg">反馈内容</text>
      </template>
      <template #body>
        <describeVue :data="taskInfo" :column="feedBackCol" :empty-value="'无'">
        </describeVue>
        <customFormNoCard v-if="formList[0].formId" :form-id="formList[0].formId" :query-value-flag="1" />
      </template>
    </u-card>
    <view v-if="subsectionList.length >= 2" class="u-m-l-30 u-m-r-30">
      <u-subsection
        :list="subsectionList"
        v-model="current"
        bg-color="#cccccc"
      ></u-subsection>
    </view>
    <view v-for="item in subsectionList" :key="item.formId">
      <template v-if="item.formId === subsectionList[current].formId">
        <customFormRender v-if="item.formId" :form-id="item.formId" :query-value-flag="1" />
      </template>
    </view>
  </view>
  <u-empty v-else mode="data"></u-empty>
</template>
<script lang="ts" setup>
import { formListApp } from '@/api/modules/form';
import describeVue from '@/components/describe.vue';
import customFormRender from '@/components/customFormRender/index.vue';
import customFormNoCard from '@/components/customFormRender/customFormNoCard.vue';


const props = defineProps<{
  taskInfo: any;
}>();

const feedBackCol = [
  {
    label: '反馈人',
    prop: 'feedbackUser',
    width: 200,
  },
  {
    label: '反馈时间',
    prop: 'feedbackTime',
    width: 200,
  },
];

const formList = ref<any[]>([]);
const subsectionList = ref<any[]>([]);
const current = ref(0);
const getFormList = () => {
  formListApp({
    pageNum: 1,
    pageSize: 10,
    belongBusinessId: props.taskInfo.taskId,
    formBusinessLevel: 4,
  }).then((res: any) => {
    console.log('getFormList', res);
    formList.value = JSON.parse(JSON.stringify(res));

    // if (res.length > 0) {
    //   activeKey.value = res[0].formId;
    //   getFormDetails(activeKey.value);
    // }
    if (res?.length > 0) {
      if (props.taskInfo.taskType === 1) {
        // getFormDetails(res[0].formId);
        res.shift();
      }
      subsectionList.value = res.map((item: any) => ({
        name: item.formName,
        formId: item.formId,
      }));
      // getFormDetails(res[0].formId);
    }
  });
};
getFormList();

</script>
<style lang="scss"></style>
